package model.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import model.vo.reservation.PaymentMethodInfoVO;
import model.vo.reservation.ReservationVO;
import model.vo.reservation.TimeTableVO;
import model.vo.theater.LocalInfoVO;

import com.ibatis.sqlmap.client.SqlMapClient;

public class ReserVationDao {
	private SqlMapClient sqlMapClient;

	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClient = sqlMapClient;
	}

	public ArrayList<HashMap> getScreeningMovieList() throws SQLException {
		// 현재 상영중인 영화 목록 리스트
		return (ArrayList<HashMap>) this.sqlMapClient.queryForList("reservation.screeningmovieList");
	}

	public ArrayList<LocalInfoVO> getLocalList() throws SQLException {
		return (ArrayList<LocalInfoVO>)sqlMapClient.queryForList("reservation.localList");
	}

	public ArrayList<LocalInfoVO> getLocalListByMovieNo(int movie_no) throws SQLException {
		return (ArrayList<LocalInfoVO>) this.sqlMapClient.queryForList("reservation.localListByMovieNo",movie_no);
	}

	public ArrayList<HashMap> getTheaterListByLocalAndMovie(HashMap map)
			throws SQLException {
		// 지역정보, 영화 정보에 따른 영화관 리스트
		System.out.println("여기뽑는중" + map);
		ArrayList<HashMap> list = (ArrayList<HashMap>) this.sqlMapClient
				.queryForList("reservation.theaterListByLocalAndMovie", map);
		System.out.println("여기뽑는중" + list);
		return list;
	}

	public ArrayList<HashMap> getTheaterListByLocal(int local_no)
			throws SQLException {
		// 지역정보에 따른 영화관 리스트

		return (ArrayList<HashMap>) this.sqlMapClient.queryForList(
				"reservation.theaterListByLocal", local_no);
	}

	public ArrayList<HashMap> getTimeTableList(TimeTableVO ttVO)
			throws SQLException {
		return (ArrayList<HashMap>) this.sqlMapClient.queryForList(
				"reservation.timeTableList", ttVO);
	}

	public ArrayList<PaymentMethodInfoVO> getPaymentMethodInfo()
			throws SQLException {
		// TODO Auto-generated method stub
		return (ArrayList<PaymentMethodInfoVO>) this.sqlMapClient
				.queryForList("reservation.paymentMethodInfo");
	}

	public void setReservationInfo(ReservationVO rVO) throws SQLException {
		this.sqlMapClient.insert("reservation.reservationInfo", rVO);
	}

	public void setReservationMyMovieInfo(ReservationVO rVO) throws SQLException {
		this.sqlMapClient.insert("reservation.reservationMyMovieInfo", rVO);

	}

	public int getMovieGradeByMovieNo(int movie_no) throws SQLException {
		return (int) this.sqlMapClient.queryForObject("reservation.movieGradeByMovieNo", movie_no);
	}

	public ArrayList<HashMap> getReservationInfo(ReservationVO rVO) throws SQLException {
		
		return (ArrayList<HashMap>)this.sqlMapClient.queryForList("reservation.getReservationInfo",rVO);
	}
	/**
	 * 결제창에서 예매정보 보여주는 메서드
	 */
	public ArrayList<HashMap> getReservationConfirm(int timetable_no) throws SQLException {
		return (ArrayList<HashMap>) sqlMapClient.queryForList("reservation.getReservationConfirm",timetable_no);
	}
	public String getMovieTitle(int movie_no) throws SQLException {
		return (String) sqlMapClient.queryForObject("reservation.getMovieTitle",movie_no);
	}

	public ArrayList<String> getConfirmedSeat(int timetable_no) throws SQLException {
		return (ArrayList<String>) sqlMapClient.queryForList("reservation.getConfirmedSeat",timetable_no);
	}

	public ArrayList<Map> getReservationList(int member_no) throws SQLException {
		return (ArrayList<Map>) sqlMapClient.queryForList("reservation.getReservationList",member_no);
	}

	public ReservationVO getReservationInfo(String res_no) throws SQLException {
		return (ReservationVO) sqlMapClient.queryForObject("reservation.getReservationInfo2",res_no);
	}

	public void insertMyMovieInfo(ReservationVO rvo) throws SQLException {
		sqlMapClient.insert("reservation.insertMyMovieInfo",rvo);
	}

	public void deleteReservation(String res_no) throws SQLException {
		sqlMapClient.delete("reservation.deleteReservation",res_no);
	}


}
